import 'package:flutter/material.dart';
import '../models/anniversary.dart';
import 'package:intl/intl.dart';

class AnniversaryListItem extends StatelessWidget {
  final Anniversary data;
  const AnniversaryListItem({super.key, required this.data});

  @override
  Widget build(BuildContext context) {
    final int daysLeft = data.daysLeft;
    final int daysPast = data.daysPast;
    final bool isFuture = daysLeft > 0;
    final int absDays = daysLeft.abs();
    return Card(
      color: Colors.white,
      shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
      elevation: 2,
      child: ListTile(
        leading: CircleAvatar(
          backgroundColor: Color(data.colorValue),
          child: Icon(IconData(data.iconCode, fontFamily: 'MaterialIcons'), color: Colors.white),
        ),
        title: Text(data.name, style: const TextStyle(fontWeight: FontWeight.bold)),
        subtitle: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Text(DateFormat('yyyy-MM-dd').format(data.date)),
            const SizedBox(height: 4),
            Row(
              children: [
                Icon(Icons.schedule, size: 16, color: Color(0xFFFF6B35)),
                const SizedBox(width: 4),
                Text('距离还有${isFuture ? absDays : 0}天',
                    style: TextStyle(
                      color: Color(0xFFFF6B35),
                      fontWeight: FontWeight.bold,
                    )),
                const SizedBox(width: 16),
                Icon(Icons.history, size: 16, color: Color(0xFF4A90E2)),
                const SizedBox(width: 4),
                Text('已过去${!isFuture ? absDays : 0}天',
                    style: TextStyle(
                      color: Color(0xFF4A90E2),
                      fontWeight: FontWeight.bold,
                    )),
              ],
            ),
          ],
        ),
        onTap: () {},
      ),
    );
  }
} 